package nxu.it.config;

import com.jfinal.config.*;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
import com.jfinal.template.Engine;
import com.mysql.cj.jdbc.MysqlDataSource;


public class MainConfig extends JFinalConfig {
    @Override
    public void configConstant(Constants constants) {
        constants.setDevMode(true);
    }

    @Override
    public void configRoute(Routes routes) {
//        扫描包，不用逐一添加
        routes.scan("nxu.it.controller");
        routes.setBaseViewPath("/WEB-INF/template");
    }

    @Override
    public void configEngine(Engine engine) {

    }

    @Override
    public void configPlugin(Plugins plugins) {
        MysqlDataSource ds=new MysqlDataSource();
        ds.setUrl("jdbc:mysql://localhost:3306/blog?useSSL=false");
        ds.setUser("root");
        ds.setPassword("123456");
        ActiveRecordPlugin arp=new ActiveRecordPlugin(ds);
        arp.setDialect(new MysqlDialect());
        arp.setDevMode(true);
        arp.setShowSql(true);
        plugins.add(arp);

    }

    @Override
    public void configInterceptor(Interceptors interceptors) {

    }

    @Override
    public void configHandler(Handlers handlers) {

    }
}
